pkg_name=bin86
version=0.16.21
src_dir=$src_dir_root/$pkg_name-$version
url=http://v3.sk/~lkundrak/dev86/$pkg_name-$version.tar.gz

cd "$src_dir_root"
rm -Rf "$pkg_name-$version"
tar zxf "$pkg_name-$version.tar.gz"

cd "$src_dir/ld"
cp -f "$builders_dir_root/$pkg_name/x86_aout.h.patch" ./
patch -Ni ./x86_aout.h.patch

cd "$src_dir"

make "CFLAGS=-O0 -D_POSIX_SOURCE" "PREFIX=/" "CC=gcc"

install_tmp_dir=/tmp/$pkg_name-$version
rm -Rf "$install_tmp_dir"
mkdir -p "$install_tmp_dir"
mkdir -p "$install_tmp_dir/man/man1"
mkdir -p "$install_tmp_dir/bin"
make install "PREFIX=$install_tmp_dir/"

install_dirs "$builders_dir_root/$pkg_name/runtime.dirs"
install_files "$builders_dir_root/$pkg_name/runtime.files" "$install_tmp_dir"
install_links "$builders_dir_root/$pkg_name/runtime.links"
elf_strip "$builders_dir_root/$pkg_name/elf-strip"

rm -Rf "$install_tmp_dir"
rm -Rf "$src_dir"
